<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>添加学生页面</title>
</head>
<body>
<form id="form">
	<table>
		<tr>
			<th>学生编号：</th>
			<th><input type="text" name="num"></th>
		</tr>
		<tr>
			<th>学生姓名：</th>
			<th><input type="text" name="name"></th>
		</tr>
		<tr>
			<th>学生性别：</th>
			<th><input type="text" name="gender"></th>
		</tr>
		<tr>
			<th>学生照片：</th>
			<th><input type="file" name="pic"></th>
		</tr>
		<tr>
			<th><input type="button" id="active" value="点击添加"></th>
		</tr>
	</table>
</form>
<script src="/static/news/js/jquery-1.12.4.min.js"></script>
<script>
	$("#active").click(function () {
		formdata = new FormData($("#form")[0]);
		$.ajax({
			url:"/addstudent",
			method:"post",
			data:formdata,
			processData:false,
			contentType:false,
			success:function (formdata) {
				alert(formdata.msg);
				console.log(formdata)
            },
			error:function (error,formdata) {
				alert("该编号已存在，请重新添加");
				console.log({"msg":"该编号已存在，请重新添加"})
            }
		})
    })
</script>
</body>
</html>